package com.huidao.servlet.goodsType;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.huidao.entity.GoodsType;
import com.huidao.service.GoodsTypeService;
import com.huidao.service.GoodsTypeServiceImp;


public class GetListGoodsType extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public GetListGoodsType() {

    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int currentpage = 1;
		long id = 0;
		String curren = request.getParameter("currentpage");
		String keyName = request.getParameter("keyname");
		if(request.getParameter("id")!=null&&request.getParameter("id")!=""){
			id = Long.parseLong(request.getParameter("id"));
		}
		if(curren!=null){
			currentpage=Integer.parseInt(curren);
		}
		GoodsTypeService gs = new GoodsTypeServiceImp();
		int totalpage = gs.getTotalPage(keyName, id);
		if(currentpage>totalpage){
			currentpage=totalpage;
		}
		List<GoodsType> list = gs.getGoodsTypeList(keyName, currentpage, id);
		request.setAttribute("list", list);
		request.setAttribute("currentpage", currentpage);
		request.setAttribute("totalpage", totalpage);
		request.getRequestDispatcher("goodsTypeList.jsp").forward(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}

}
